package cn.mw.cmdb.service;

import cn.mw.cmdb.entity.ModelInfo;
import cn.mw.cmdb.mongoMapper.ModelInfoMapper;
import cn.mw.components.mongodb.tool.CriteriaWrapper;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
import java.util.List;

@Component
public class ModelManage {

    private ModelInfoMapper modelInfoMapper;

    public ModelManage(ModelInfoMapper modelInfoMapper){
        this.modelInfoMapper = modelInfoMapper;
    }

    public List<ModelInfo> findModelInfoByIds(List<String> ids) throws Exception{
        if(null == ids){
            return null;
        }
        Criteria criteria = CriteriaWrapper.where(ModelInfo::getId).in(ids);
        List<ModelInfo> list = modelInfoMapper.find(new Query(CriteriaWrapper.where(ModelInfo::getDelFlag).is(false)).addCriteria(criteria));
        return list;
    }
}
